import java.io.Serializable;
import java.io.FileOutputStream;
import java.io.FileInputStream;
import java.io.ObjectOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;

class Student implements Serializable
	{
	String name;
	String address;
	int roll;
	double score;
	
	Student(String n, String a. int r, double s)
		{
		this.name = n;
		this.address = a;
		this.roll = r;
		this.score = s;
		}
	
	public static void Serialize(Student s)
		{
		try
			{
			FileOutputStream fos = new FileOutputStream("student.ser");
			ObjectOutputStream oos = new ObjectOutputStream(fos);
			oos.writeObject(s);
			oos.close();
			fos.close();
			}
		catch(IOException ioe)
			{
			ioe.printStackTrace();
			}
		}
	
	public static void Deserialize(FileInputStream fis)
		{
		Student s;
		try
			{
			ObjectInputStream ois = new ObjectInputStream(fis);
			s = (Student) ois.readObject();
			ois.close();
			fis.close();
			}
		catch(IOException ioe)
			{
			ioe.printStackTrace();
			return;
			}
		catch(ClassNotFoundException cnfe)
			{
			System.out.println("Student Class Not Found");
			cnfe.printStackTrace();
			return;
			}
		showStudent(s);
		
		}
	void showStudent(Student s)
		{
		System.out.println("Student Details.....");
		System.out.println("Name : " + s.name);
		System.out.println("Address : " + s.address);
		System.out.println("Roll : " + s.roll);
		System.out.println("Score : " + s.score);
		}
	}
	
class Serialize3Object
	{
	public static void main(String args[])
		{
		Student s[] = new Student[5];
		Student s[0] = new Student("Rajiv","Bangalore", 1,99.32);
		Student s[1] = new Student("Sanjeev", "Bangalore", 2, 98.32);
		Student s[2] = new Student("Pulkit", "Bangalore", 3, 94.32);
		Student s[3] = new Student("Maqbul", "Bangalore", 4, 97.52);
		Student s[4] = new Student("Niraj", "Bangalore", 5, 99.92);	
		for(int i=0; i<s.length; i++)
			{
			Student.Serialize(s[i]);
			}
		
		for(int j=0;j<s.length;j++
			Student.Deserialize();
		}
	}
